/**
 * Created by hjy on 2017/9/14.
 */
module.exports = function (grunt) {
    grunt.initConfig({
        watch: {
            jade: {
                files: ['views/**'],
                options: {
                    livereload: true
                }
            },
            js: {
                files: ['public/js/**', 'models/**/*.js', 'schemas/**/*.js'],
                //tasks: ['jshint'],
                options: {
                    livereload: true
                }
            }
        },

        /**
         * watchedFolders 添加监听目录
         */
        nodemon: {
            dev: {
                options: {
                    file: 'app.js',
                    args: [],
                    ignoredFiles: ['README.md', 'node_modules/**', '.DS_Store'],
                    watchedExtensions: ['js'],
                    watchedFolders: ['./'],
                    debug: true,
                    delayTime: 1,
                    env: {
                        PORT: 3000
                    },
                    cwd: __dirname
                }
            }
        },

        concurrent: {
            tasks: ['nodemon', 'watch'],
            options: {
                logConcurrentOutput: true
            }
        }
    })


    //只要有文件添加修改删除 就会重新执行
    grunt.loadNpmTasks('grunt-contrib-watch')

    //实时监听app.js文件
    grunt.loadNpmTasks('grunt-nodemon')

    //监听sass less
    grunt.loadNpmTasks('grunt-concurrent')

    //不会因为警告 错误终端执行
    grunt.option('force', true)

    // 注册一个默认任务
    grunt.registerTask('default', ['concurrent'])
}